$(function() {
    $("#title").on("keydown",function(event) {
        if(event.keyCode === 13) {
            var local = getDate();
            // console.log(local);
            local.push({title:$(this).val(),done:false});
            saveDate(local);
            load();
        }
    });

    function getDate() {
        var data = localStorage.getItem("todolist");
        if(data !== null) {
            return JSON.parse(data)
        }else {
            return []
        }
    }

    function saveDate(data) {
        localStorage.setItem('todolist',JSON.stringify(data));
    }

    function load() {
      var data = getDate();

      $each(data,function(i, n) {
        $("ol").prepend("<li><input type='checkbox'> <p></p><a href='javascript:;'></a>/li>")
})
    }
})